package day13;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class demo2 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);


    }

    public int maxLength (int[] arr) {
        int n=arr.length;
        if (n==0)return 0;
        int left=-1;
        int right=0;
        int ret=0;
        Set<Integer>set=new HashSet<>();
        while (right<n){
            if (!set.contains(arr[right])){
                set.add(arr[right++]);
                ret=Math.max(ret, set.size());
            }else {
                while (set.contains(arr[right])){
                    set.remove(arr[++left]);
                }
            }
        }
        return ret;
    }



}
